package com.huawei.appmarket.support.account;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import com.huawei.appgallery.foundation.account.bean.UserSession;
import com.huawei.secure.android.common.intent.SafeIntent;
import java.util.Objects;
import o.cem;
import o.cem.e;
import o.diu;
import o.Logger;
import o.dof;
import o.eod;
import o.eos;
import o.ll;

public class HwAccountReceiver extends BroadcastReceiver implements e {
    private static final cem ॱ = new cem();

    public void onReceive(Context context, Intent intent) {
        ॱ.ˋ(context, new SafeIntent(intent), this);
    }

    public boolean isSameBroadcast(SafeIntent safeIntent, SafeIntent safeIntent2) {
        return Objects.equals(safeIntent.getAction(), safeIntent2.getAction()) && Objects.equals(safeIntent.getStringExtra("userId"), safeIntent2.getStringExtra("userId"));
    }

    public void onReceiveNoRepeat(Context context, SafeIntent safeIntent) {
        String action = safeIntent.getAction();
        boolean ˋ = diu.ˊ().ˋ();
        Logger.ˎ("HwAccountReceiver", "receive action=" + action + ", isAgreeLocalProtocol=" + ˋ);
        if (!ˋ) {
            Logger.ˋ("HwAccountReceiver", "isAgreeLocalProtocol is false");
            if ("com.huawei.hwid.ACTION_REMOVE_ACCOUNT".equals(action)) {
                action = safeIntent.getStringExtra("userId");
                UserSession instance = UserSession.getInstance();
                if (action != null && action.equals(instance.getUserId())) {
                    eod.ˏ(context);
                }
                diu.ˊ().ˏ();
                Intent intent = new Intent();
                intent.setAction("com.huawei.systemmanager.action.CHANGE_HOME_COUNTRY");
                ll.ˏ(context).ˋ(intent);
            }
        } else if ("com.huawei.hwid.ACTION_REMOVE_ACCOUNT".equals(action)) {
            action = safeIntent.getStringExtra("userId");
            ˋ = dof.ˋ(action);
            boolean ˏ = eos.ˏ(context);
            Logger.ˎ("HwAccountReceiver", "HwId Logout, hasAccount: " + ˏ + ", userIdIsEmpty: " + ˋ);
            if (!ˏ && !ˋ) {
                if (action.equals(UserSession.getInstance().getUserId())) {
                    eod.ˏ(context);
                } else {
                    Logger.ˋ("HwAccountReceiver", "logout userid not equal current userid");
                }
            }
        }
    }
}
